package com.insight.common.message.websocket.factory;

import com.insight.common.message.websocket.handler.IWebSocketHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author JinPengDong
 * @date 2022/8/24
 */
@Component
public class WebSocketHandlerFactory {

    @Autowired
    private List<IWebSocketHandler> webSocketHandlers;

    public IWebSocketHandler getWebSocketHandler(String support){
        for (IWebSocketHandler webSocketHandler : webSocketHandlers) {
            if(webSocketHandler.support(support)){
                return webSocketHandler;
            }
        }
        return null;
    }

}
